

package com.wake.widget.widget.popup;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.wake.widget.widget.NMUIWrapContentListView;

public class NMUIPopups {

    public static NMUIPopup popup(Context context) {
        return new NMUIPopup(context,
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    public static NMUIPopup popup(Context context, int width) {
        return new NMUIPopup(context,
                width,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    public static NMUIPopup popup(Context context, int width, int height) {
        return new NMUIPopup(context, width, height);
    }

    /**
     * show a list with popup
     *
     * @param context             activity context
     * @param width               the with for the popup content
     * @param maxHeight           the max height of popup, it is scrollable if the content is higher then maxHeight
     * @param adapter             the adapter for the list view
     * @param onItemClickListener the onItemClickListener for list item view
     * @return NMUIPopup
     */
    public static NMUIPopup listPopup(Context context, int width, int maxHeight,
                                      BaseAdapter adapter,
                                      AdapterView.OnItemClickListener onItemClickListener) {
        ListView listView = new NMUIWrapContentListView(context, maxHeight);
        listView.setAdapter(adapter);
        listView.setVerticalScrollBarEnabled(false);
        listView.setOnItemClickListener(onItemClickListener);
        listView.setDivider(null);
        return popup(context, width).view(listView);
    }

    public static NMUIFullScreenPopup fullScreenPopup(Context context) {
        return new NMUIFullScreenPopup(context);
    }

    public static NMUIQuickAction quickAction(Context context, int actionWidth, int actionHeight) {
        return new NMUIQuickAction(context, ViewGroup.LayoutParams.WRAP_CONTENT, actionHeight)
                .actionWidth(actionWidth)
                .actionHeight(actionHeight);
    }
}
